﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Refugees.Repositories
{
    internal class RecuestRepository : ModelRepository
    {
        internal List<Models.Recuest> GetRecuests(int userId)
        {
            if (UserRepository.User.role_id == 2)
            {
                return Context.Recuest.Where(i => i.IdOrganization == null || i.IdOrganization == User.organization_id).ToList();
            }
            return Context.Recuest.Where(i => i.PersonalData.IdUser ==userId).ToList();
        }

        internal void AddRecuest(Models.Recuest recuest)
        {
            recuest.Status = "В обработки";
            recuest.Data = DateTime.Now;
            Context.Recuest.Add(recuest);
        }
    }
}
